<?php 

	/*
		Jax Calendar v1.3 - Copyright (c) 2002-2004, Andreas John aka Jack (tR)
		This program and it's moduls are Open Source in terms of General Public Licens (GPL) v2.0

		eventlist.inc.php 		(the list of events)
	*/	

$do = "default";

	$now_start = intval(gmmktime(0,0,0,$cal_month,$cal_day,$cal_year,$is_dst));
	$now_stop  = intval(gmmktime(23,59,59,$cal_month,$cal_day,$cal_year,$is_dst));
	$now_stamp = intval(gmmktime(0,0,0,$cal_month,$cal_day,$cal_year,$is_dst));
	
// ?do=...(called without do parameter)
if ( $do=="default" )
{
	if (!empty($_GET["next_follows"])) $nxt = $_GET["next_follows"]; else $nxt = "0";

	$num_dates = $calendar_list->entries();
	
	$red_data = array();
	$the_last_entry = false;

	$calendar_list->get_entry( 0, $red_data);
	$i=1;

	if ($nxt != "0")
	{
		while ( !$calendar_list->eol() && $red_data["event_key"] != $nxt )
		{
			$calendar_list->get_next_entry( $red_data );
			$i++;
		} 
	}
	else
	{
		while ( !$calendar_list->eol() && ($now_stamp > intval( $red_data["event_start"]) ) )
		{
			$calendar_list->get_next_entry( $red_data );
			$i++;
		} 		
	}

	if (!$calendar_list->eol() && $i < $num_dates)
	{
		if ($nxt!="0") $calendar_list->get_next_entry( $red_data );

		$next_evt_year  = intval(gmdate( "Y", $red_data["event_start"] ));
		$next_evt_month = intval(gmdate( "m", $red_data["event_start"] ));
		$next_evt_day   = intval(gmdate( "d", $red_data["event_start"] ));
		
		$date_str = "";
		if ( $red_data["x24"] == "1" )
		{
			$d_start = gmdate("d.m.Y",$red_data["event_start"]);
			$d_end   = gmdate("d.m.Y",$red_data["event_end"]);
		
			if ($d_start != $d_end) 
			{
				$date_str .= $d_start . " -<br>" . $d_end;
			} else $date_str .= $d_start;
		}
		else
		{
			$date_str = gmdate("d.m.Y H:i",$red_data["event_start"]);

			if ($red_data["event_start"] != $red_data["event_end"]) 
			{
				$date_str .= " -<br>" . gmdate("d.m.Y H:i",$red_data["event_end"]);
			}				
		}

  		echo '<div class="next_event_select">'."\n"
  		."{$loc_lang["next_event"]}: ".'&nbsp;<a href="'.$PHP_SELF."?next_follows=".$red_data["event_key"]."&Y=$next_evt_year&m=$next_evt_month&d=$next_evt_day&do=show_event&key=".$red_data["event_key"]."&cal_id=$cal_id&language=$language&evt_date=".urlencode($date_str).'&evt_title='.urlencode($red_data["event_title"]).'">'.$red_data["event_title"]."</a>\n"
  		."</div>\n";
		
	}	
}
?>